import datetime
from flask import Blueprint,request,jsonify
from flask.json import JSONEncoder
import requests

from views.db import Db

import json

from utils.jwtc import myjwt

from utils.Make_password import make_password

from utils.myfile import MyFile

from utils.redis import rs

from utils.acl import ACL

import redis

import re

from views.db import db

from utils.acl import  acl

from utils.myfile import get_data

import time

import functools

bp_customer = Blueprint("customer",__name__)


@bp_customer.route('/customer_reg', methods=['POST'])
def customer_reg():

    data = get_data()

    now = int(time.time())
    sql = "insert into customer(name,company_name,manager_id,refromid,addtime) values('%s','%s',%d,%d,%d)"%(data['name'],data['company'],int(data['manager_id']),int(data['refromid']),now)
    db.update(sql)
    db.commit()

    return jsonify({"code":200,"msg":"添加成功"})


@bp_customer.route('/managelist')
def managelist():

    sql = " select * from customer_manager"
    res = db.get_all(sql)

    return jsonify({"code":200,"list":res})


@bp_customer.route('/get_regform')
def get_regform():

    sql = " select * from reg_form "
    res = db.get_all(sql)

    return jsonify({"code":200,"list":res})

